package com.lovo.cloud.controller;


import com.lovo.cloud.model.dos.OrderDO;
import com.lovo.cloud.service.OrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author luo
 * @since 2020-12-04
 */
@RestController
public class OrderController {

    @Resource
    private OrderService orderService;

    @GetMapping("/order")
    public String byTicket(OrderDO orderDO){
        boolean b = orderService.saveOrder(orderDO);
        if (b == true) {
            return "已下单，待出票";
        }
        return "下单失败";
    }

    @GetMapping("/update")
    public String updateOrder(String orderNum,Boolean type){
        boolean b = orderService.updateTag(orderNum, type);
        if (b == true) {
            return "已出票，取票码为："+orderNum;
        }
        return "票已售罄，购票失败，已退款";
    }


}

